

#这个镜像的基础镜像是centos7
FROM centos:7

# 作者
MAINTAINER tanran

# 搜索可以安装的jdk版本，由于网速问题先注释
#RUN yum search java | grep jdk

#安装Jdk
RUN yum -y install java-1.7.0-openjdk

# 安装wget工具
RUN yum -y install wget

# 创建一个文件夹 /web/tomcat
RUN mkdir -p /web/tomcat/

# 切换工作目录到/web/下
WORKDIR /web/tomcat/

# 下载tomcat文件
RUN wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.82/bin/apache-tomcat-7.0.82.tar.gz

# 安装tar工具
RUN yum -y install tar

# 解压tomcat压缩文件
RUN tar zxvf apache-tomcat-7.0.82.tar.gz

# 复制多个tomcat,并更名为tomcat1 2 3
RUN mv /web/tomcat/apache-tomcat-7.0.82 /web/tomcat/apache-tomcat-01
RUN cp -rf /web/tomcat/apache-tomcat-01 /web/tomcat/apache-tomcat-02
RUN cp -rf /web/tomcat/apache-tomcat-01 /web/tomcat/apache-tomcat-03


#替换配置文件
ADD tomcat/tomcat02/server.xml /web/tomcat/apache-tomcat-02/conf/server.xml
ADD tomcat/tomcat03/server.xml /web/tomcat/apache-tomcat-03/conf/server.xml


# 删除tomcat默认的项目文件
# RUN rm -rf *

#创建nginx目录
RUN mkdir -p /web/nginx

#复制nginx,准备安装
ADD nginx/nginx-1.10.3.tar.gz  /web/nginx/
ADD nginx/openssl-1.0.1c.tar.gz  /web/nginx/
ADD nginx/zlib-1.2.11.tar.gz  /web/nginx/
ADD nginx/pcre-8.38.tar.gz   /web/nginx/

#切换到nginx目录
WORKDIR /web/nginx
RUN ls -lt

#解压nginx
#RUN tar zxvf nginx-1.10.3.tar.gz
#RUN tar zxvf openssl-1.0.1c.tar.gz
#RUN tar zxvf zlib-1.2.11.tar.gz
#RUN tar zxvf pcre-8.38.tar.gz

#安装make gcc-c++
RUN yum install make -y
RUN yum install gcc-c++ -y
RUN yum install pcre-devel -y
RUN yum install openssl openssl-devel -y

#安装Perl 5
#WORKDIR /web/nginx/
#RUN wget http://www.cpan.org/src/5.0/perl-5.24.0.tar.gz
#RUN tar -xzf perl-5.24.0.tar.gz 
#WORKDIR /web/nginx/perl-5.24.0
#RUN ./Configure -des -Dprefix=$HOME/localperl 
#RUN make && make test && make install 

#切换openssl-1.0.1c目录
#WORKDIR /web/nginx/openssl-1.0.1c
#RUN ls -l
#RUN ./config && make && make install

#切换zlib-1.2.11目录
WORKDIR /web/nginx/zlib-1.2.11
RUN ./configure  && make && make install

#切换pcre-8.38目录
WORKDIR /web/nginx/pcre-8.38
RUN ./configure  && make && make install

#切换到nginx目录
WORKDIR /web/nginx/nginx-1.10.3
RUN ./configure && make && make install

#更改nginx的配置文件
ADD nginx/nginx.conf /web/nginx/
RUN mv /web/nginx/nginx.conf /usr/local/nginx/conf/nginx.conf


#公布tomcat的8080端口
EXPOSE 8080
EXPOSE 8081
EXPOSE 8082
#公布nginx的端口
EXPOSE 88


#安装redis
RUN mkdir -p /web/redis/
ADD redis/redis-2.8.18.tar.gz /web/redis/
#RUN ls -at
#RUN tar -zxvf redis-2.8.18.tar.gz
WORKDIR /web/redis/redis-2.8.18
RUN make
ADD redis/redis0.conf  /web/redis/redis-2.8.18/
ADD redis/redis1.conf  /web/redis/redis-2.8.18/
ADD redis/redis2.conf  /web/redis/redis-2.8.18/
ADD redis/redis3.conf  /web/redis/redis-2.8.18/
RUN mkdir -p /redis_data/redis0
RUN mkdir -p /redis_data/redis1
RUN mkdir -p /redis_data/redis2
RUN mkdir -p /redis_data/redis3
ADD redis/sentinel0.conf  /web/redis/redis-2.8.18/
ADD redis/sentinel1.conf  /web/redis/redis-2.8.18/
ADD redis/sentinel2.conf  /web/redis/redis-2.8.18/
ADD redis/sentinel3.conf  /web/redis/redis-2.8.18/

##实现共享session
ADD tomcat/context.xml /web/tomcat/apache-tomcat-01/conf/context.xml
ADD tomcat/context.xml /web/tomcat/apache-tomcat-02/conf/context.xml
ADD tomcat/context.xml /web/tomcat/apache-tomcat-03/conf/context.xml

ADD tomcat/lib /web/tomcat/apache-tomcat-01/lib
ADD tomcat/lib /web/tomcat/apache-tomcat-02/lib
ADD tomcat/lib /web/tomcat/apache-tomcat-03/lib

ADD tomcat/test.jsp /web/tomcat/apache-tomcat-01/webapps/ROOT/test.jsp
ADD tomcat/test.jsp /web/tomcat/apache-tomcat-02/webapps/ROOT/test.jsp
ADD tomcat/test.jsp /web/tomcat/apache-tomcat-03/webapps/ROOT/test.jsp


#公布tomcat的8080端口
EXPOSE 6379
EXPOSE 6380
EXPOSE 6381
EXPOSE 6382
EXPOSE 26379
EXPOSE 26380
EXPOSE 26381
EXPOSE 26382


#复制启动脚本并执行
ADD start.sh /web/
WORKDIR /web/
RUN chmod -R 777 start.sh
#ENTRYPOINT ["./start.sh", "run"]
#
# 启动tomcat
#ENTRYPOINT ["../../bin/catalina.sh", "run"]

